package org.huangrui.config;

import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.huangrui.serbice.LawAssistant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author hr
 * @Create 2025-11-09 14:21
 * @Description: 知识出处 知识出处，https://docs.langchain4j.dev/tutorials/chat-memory/#eviction-policy
 **/
@Configuration
public class LLMConfig {
    @Bean
    public ChatModel chatModel() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("aliQwen-api"))
                .modelName("qwen-long")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean(name = "chat")
    public LawAssistant chatAssistant(ChatModel chatModel) {
        return AiServices.create(LawAssistant.class, chatModel);
    }

}
